#include <sys/syscall.h>
#include <mips/regdef.h>

	.text
	.align	2
	.globl 	myputchar
	.ent	myputchar

myputchar:
	  .frame $fp, 48, ra
	  .set	noreorder
	  .cpload	t9
	  .set	reorder
	  subu	sp, sp, 48
	  .cprestore 32
	  #subu    sp,sp,24
	  sw		ra,40(sp)
	  sw		$fp,36(sp)
	  sw		gp,32(sp)
	  move	$fp,sp

	  sw		a0,48($fp)
	  li		v0,SYS_write
	  li		a0,1
	  la		a1,48($fp)
	  li		a2,1
	  syscall

	  bne	a3, zero, write_error
	  li	t0, 1
	  bne	v0, t0, write_error

finp:	
	  move	sp,$fp
	  lw	ra,40(sp)
	  lw	$fp,36(sp)
	  lw	gp,32(sp)
	  addu	sp,sp,48
	  j	ra


	


write_error:
	li	v0, SYS_exit
	li	a0, 1
	syscall

	.end	myputchar
